package it.unibo.imola.utils;

import java.util.Map;
import java.util.Map.Entry;

public class ToStringUtils {

	public static String toString(Map<?, ?> map) {
		StringBuilder creator = new StringBuilder();
		creator.append("{");
		for (Entry<?, ?> entry : map.entrySet()) {
			creator.append("<");
			creator.append(entry.getKey().toString());
			creator.append("=");
			creator.append(entry.getValue().toString());
			creator.append(">");
		}
		creator.append("}");
		return creator.toString();
	}
	
	public static String toString(Class<?>[] array) {
		StringBuilder creator = new StringBuilder();
		creator.append("{");
		int i = 0;
		for(Class<?> c : array){
			if(i>0)
				creator.append(", ");
			creator.append(c.getSimpleName());
			i++;
		}
		creator.append("}");
		return creator.toString();
	}
	
	public static String toString(Object[] array) {
		StringBuilder creator = new StringBuilder();
		creator.append("{");
		int i = 0;
		for(Object obj : array){
			if(i>0)
				creator.append(", ");
			creator.append("("+obj.getClass().getSimpleName()+")[" + obj + "]");
			i++;
		}
		creator.append("}");
		return creator.toString();
	}
}
